package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-21 14:55
 */
public class Solution_0507 {
    /**
     * 完美数
     *
     * @param num
     * @return
     */
    public boolean checkPerfectNumber(int num) {
        if (num == 1) return false;
        int count = 1;
        for (int i = 2, j = num / 2; i < j; ) {
            if (i * j == num) {
                count = count + i + j;
                i++;
                j--;
            } else if (i * j > num) {
                j--;
            } else {
                i++;
            }
        }


        return count == num;
    }
}
